/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * All Rights Researved.
 *
 * This library is developed and distributed for free usage,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * You can redistribute and/or modify it under the terms of the
 * Simplified BSD License
 *
 *
 *
 *
 *
 *
 *
 * usage: draw brushing on the Dynamic layers
 * @author: jin Chen 
 * @date: Jun 30, 2003$
 * @version: 1.0
 */
package edu.psu.geovista.app.pcp.plot.layer.operation;

import java.awt.*;
import java.awt.geom.GeneralPath;

public class DrawLineOp extends BasicLayerOp{
    private Point from;
    private Point to;

    private GeneralPath path=new GeneralPath();

     public void paint(Graphics g) {
        Graphics2D g2d=(Graphics2D)g;
        g2d.setColor(this.color );

        Stroke olds=g2d.getStroke() ;
        BasicStroke bs=new BasicStroke(2);
        g2d.setStroke(bs);

        g2d.draw(path);
        //g2d.drawLine(from.x,from.y,to.x,to.y);
       //g2d.drawRect(x,y,size.width,size.height );
        g2d.setStroke(olds);


     }

    public void drawLine(Point from,Point to) {
        if(this.from==null){
            this.from=from;
            path.moveTo(from.x,from.y);
        }
        path.lineTo(to.x,to.y);
        /*this.from = from;
        this.to=to;*/
    }
    public void reset() {
        this.from = null;
        path.reset();
    }

}
